﻿"use strict";

module.exports = appInfo => {
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + "_1533025443235_3863";

  // add your config here
  config.middleware = ["auth"];
  config.security = {
    csrf: {
      enable: false
    }
  };

  // config.redis = {
  //   client: {
  //     port: 6379,
  //     host: "129.28.159.96",
  //     password: "zyy123456",
  //     db: 0
  //   }
  // };

  config.io = {
    init: {}, // passed to engine.io
    namespace: {
      "/": {
        connectionMiddleware: ["auth"],
        packetMiddleware: []
      },
      "/example": {
        connectionMiddleware: ["auth"],
        packetMiddleware: []
      }
    },
    // redis: {
    //   host: "129.28.159.96",
    //   port: 6379,
    //   auth_pass: "zyy123456",
    // }
  };


  config.mongoose = {
    client: {
      url: "mongodb://localhost:27017", //你的数据库地址
      options: {
        // useNewUrlParser: true,
        user: 'admin', // 数据库用户名
        pass: 'admin',

      }
    }
  };

  config.kafka = {
    // kafka 配置
    client: {
      kafkaHost: 'ckafka-xjvq57g8.ap-guangzhou.ckafka.tencentcloudmq.com:50001'
    },

    // producer 配置
    producer: {
      // 1=leader确认, 2=所有ISR副本确认, -1或0=all确认
      requireAcks: 1,
    },

    // consumer 配置
    consumer: {
      autoCommit: true,
      groupId: 'egg-kafka-group',
      // 从最新的消息开始消费, 如果设置为earliest则表示从最早的消息开始消费
      fromOffset: 'latest'
    }
  };

  return config;
};